package com.zhao;

import com.zhao.abstractExpression.AbstractExpression;
import com.zhao.context.Context;
import com.zhao.nonterminalExpresion.Minus;
import com.zhao.nonterminalExpresion.Plus;
import com.zhao.teminalExpression.Variable;

public class Client {
    public static void main(String[] args) {
        Context context = new Context();

        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");

        context.assign(a, 1);
        context.assign(b, 2);
        context.assign(c, 3);
        context.assign(d, 4);

        AbstractExpression expression = new Plus(a, new Plus(b, new Minus(c, d)));

        int interpret = expression.interpret(context);
        System.out.println("expression:" + expression.toString() + " = " + interpret);
    }
}
